/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * Description:
 * Author: huawei
 * Create: 2019-10-15
 */

#ifndef DEVDRV_SMMU_H
#define DEVDRV_SMMU_H

#include "devdrv_interface.h"
#include "devdrv_pci.h"

#define DEVDRV_SMMU_NON_TRANS_MSG_DESC_SIZE 0x200

/* agent smmu only can transform 32 addr one time */
#define DEVDRV_AGENT_SMMU_SUPPORT_MAX_NUM 32
struct devdrv_host_dma_addr_to_pa_cmd {
    u32 cnt;
    u64 dma_addr[0];
};

struct devdrv_dma_node *devdrv_host_dma_addr_to_pa(int dev_id, struct devdrv_dma_node *dma_node, u32 node_cnt);
void devdrv_host_dma_node_free(int dev_id, struct devdrv_dma_node *real_dma_node);
void devdrv_pdev_sid_init(struct devdrv_pci_ctrl *pci_ctrl);
void devdrv_pdev_sid_uninit(struct devdrv_pci_ctrl *pci_ctrl);
int devdrv_smmu_init_msg_chan(struct devdrv_pci_ctrl *pci_ctrl);
void devdrv_smmu_uninit_msg_chan(struct devdrv_pci_ctrl *pci_ctrl);

#endif